package org.kumas.bigdata.hdfs3.rpc;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/*************************************************
 * TODO_Kumas
 *  Author： KumasZhang
 *  DateTime： 2021-12-06 8:22
 *  Description： 
 **/
public class RegInfo implements Writable {
    public String nodeId;
    public int cpu;
    public int mem;

    public RegInfo() {
    }

    public RegInfo(String nodeId, int cpu, int mem) {
        this.nodeId = nodeId;
        this.cpu = cpu;
        this.mem = mem;
    }


    @Override
    public void write(DataOutput out) throws IOException {
        out.writeUTF(nodeId);
        out.writeInt(cpu);
        out.writeInt(mem);
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        nodeId = in.readUTF();
        cpu = in.readInt();
        mem = in.readInt();
    }

    @Override
    public String toString() {
        return "RegInfo{" +
                "nodeId='" + nodeId + '\'' +
                ", cpu=" + cpu +
                ", mem=" + mem +
                '}';
    }
}
